Same script, different behavior [migrated]

Posted by Antoine_935 on Server Fault See other posts from Server Fault or by Antoine_935
Published on 2012-09-01T20:11:50Z Indexed on 2012/09/01 21:39 UTC
Read the original article Hit count: 177

Filed under:
|

I just stumbled upon an interesting bug... Still trying to figure out what is exactly happening. Maybe you can help.

First, the context. I'm currently building yet another man to html converter (for some reasons I won't motivate here, but I need it).

So, have a look at the screenshot below (see the link), more precisely at the outlined spots. See? On the upper shell, I have &lt ; and &gt ;, that is, escaped html. While on the shell below I have < and > directly.

But as you can see (or do I seriously need looking glass ?), the command man 2 semget | webmanneris the same on both sides, as is the which webmanner. The two are executed roughly at the same moment, with no modification made to the script between.

[Oops, cannot post pictures just yet... Here comes the link]

http://aspyct.org/media/webmanner-bug.png

But the shell below is older (open about 1 hour ago). Newer shells all print out &lt ;. So my first guess was that it somehow had a cached reference to the old inode of the file, or old blocks or whatever.

So I modified parts of the script, at the start and then at the end, to print different messages. And, surprise, the message shown up on both terminals. But still, same difference between &lt ; and <.

I'm confused... How to explain that behavior? I'm working on a OSX 10.8 (Mountain Lion)

EDIT: OK, there is one big difference: the shell below uses ruby 1.9.3, while above is 1.8.7. Is there any known difference in string handling between the two versions ?

© Server Fault or respective owner

Related posts about scripting

Related posts about shell